//
//  FingerDrawViewController.m
//  FingerDraw
//
//  Created by coolluck on 10. 1. 19..
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "MyUIView.h"
#import "FingerDrawViewController.h"

@implementation FingerDrawViewController



/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	UIScreen* screen = [UIScreen mainScreen];
	CGRect frame = [screen applicationFrame];
  
	UIImage* img = [UIImage imageNamed:@"sample.jpg"];
	UIImageView* imageView = [[UIImageView  alloc] initWithImage:img];
	_imageView = imageView;
	[_imageView retain];
	[imageView setUserInteractionEnabled:YES];
	CGSize imgSize = [img size];
	[img release];
	
	UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:frame];
	[scrollView setScrollEnabled:YES];
	[scrollView setContentSize:imgSize];
	[scrollView addSubview:imageView];
	[imageView release];
	[scrollView setMaximumZoomScale:2.0f];
	[scrollView setMinimumZoomScale:0.1f];
	[scrollView setDelegate:self];
	self.view = scrollView;
	[scrollView release];
}

- (UIView*)viewForZoomingInScrollView:(UIScrollView*) scrollView
{
	return _imageView;
}

- (void)scrollViewDidEndZooming:(UIScrollView*) scrollView withView:(UIView*) atScale:(float)scale
{
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
	return YES;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[super dealloc];
	[_imageView release];
	_imageView = nil;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
	UIAlertView* alert = [[UIAlertView alloc]
						  initWithTitle:@"터치"
						  message:@"뷰를 터치했습니다."
						  delegate:nil
						  cancelButtonTitle:nil
						  otherButtonTitles:@"확인", nil];
	[alert show];
	[alert release];
}

@end
